package com.syezon.android.base.download;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/4/18.
 */
public interface IDownloadManager {

    /**
     * @return return currentTaskList
     */
    Map<String, DownloadTask> getCurrentTaskList();

    /**
     * if task already exist,return the task,else return null
     *
     * @param task
     * @param listener
     * @return
     */
    DownloadTask addDownloadTask(DownloadTask task, IDownloadTaskListener listener);

    /**
     * if return null,the task does not exist
     *
     * @param taskId
     * @return
     */
    DownloadTask resume(String taskId);


    void addDownloadListener(DownloadTask task, IDownloadTaskListener listener);

    void removeDownloadListener(DownloadTask task, IDownloadTaskListener listener);

    DownloadTask addDownloadTask(DownloadTask task);

    void cancel(DownloadTask task);

    void cancel(String taskId);

    void pause(DownloadTask task);

    void pause(String taskId);


    List<DownloadInfo> loadAllDownloadEntityFromDB();

    /**
     * if not exists return null
     * the task maybe not in the running task list,
     * you can add{@link #addDownloadTask(DownloadTask) addDownloadTask}
     *
     * @return
     */
    List<DownloadTask> loadAllDownloadTaskFromDB();

    /**
     * return all task include running and db
     *
     * @return
     */
    List<DownloadTask> loadAllTask();

    /**
     * return the task in the running task list
     *
     * @param taskId
     * @return
     */
    DownloadTask getCurrentTaskById(String taskId);

    /**
     * if not exists return null
     * the task maybe not in the running task list,
     * you can add{@link #addDownloadTask(DownloadTask) addDownloadTask}
     *
     * @param taskId
     * @return
     */
    DownloadTask getTaskById(String taskId);

    /**
     * if not exists return null
     * the task maybe not in the running task list,
     * you can add{@link #addDownloadTask(DownloadTask) addDownloadTask}
     *
     * @param taskId
     * @return
     */
    DownloadTask getDBTaskById(String taskId);
}
